package com.linkoog.devtools.code_generator.wizard.generate.database.table.dialog.datasource.panel;

import com.linkoog.devtools.code_generator.Bundle;
import com.linkoog.devtools.code_generator.CodeGenIcons;
import com.linkoog.devtools.code_generator.database.dao.DatabaseDao;
import com.linkoog.devtools.code_generator.database.dao.DatabaseDaoFactory;
import com.linkoog.devtools.code_generator.database.domain.ConnectionInfo;
import com.linkoog.devtools.code_generator.database.domain.DatabaseInfo;
import com.linkoog.devtools.code_generator.database.domain.DbType;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.ValidationInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.components.JBLoadingPanel;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import com.intellij.util.ui.JBUI;
import org.apache.commons.lang3.StringUtils;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.util.Arrays;
import java.util.List;

public class RightPanelBuilder implements Disposable {

    private JPanel myMainPanel;
    private JPanel contextPanel;

    private JTextField nameTextField;
    private JTextArea descriptionTextArea;


    private JTabbedPane tabbedPane;

    private JPanel simpleConfigPanel;
    private JComboBox dbTypeComboBox;
    private JTextField hostTextField;
    private JTextField portTextField;
    private JTextField userTextField;
    private JPasswordField passwordField;

    private JComboBox databaseComboBox;
    private JComboBox schemaComboBox;

    private JButton testConnButton;


    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), this::dispose);


    public RightPanelBuilder() {
        loadingPanel.add(myMainPanel, BorderLayout.CENTER);
        loadingPanel.setMinimumSize(JBUI.size(350, -1));
        loadingPanel.setPreferredSize(JBUI.size(350, -1));

        //nameTextField.setToolTipText("连接名是唯一的！当连接名存在列表中，执行的是修改操作，只有连接名不在列表中，才是新增操作。");

        initDbTypeComboBox();
        //resetConnPanel(DbType.MYSQL);
    }

    private void initDbTypeComboBox() {
        dbTypeComboBox.setRenderer(new DbTypeComboBoxCellRender());
        dbTypeComboBox.addItem(EmptyItem.newInstance().setIcon(CodeGenIcons.empty).setText("请选择"));
        for (DbType dbType : DbType.values()) {
            dbTypeComboBox.addItem(dbType);
        }

        dbTypeComboBox.addItemListener(event -> {
            if (event.getStateChange() == ItemEvent.SELECTED) {
                Object selected = event.getItem();
                if (selected instanceof DbType) {
                    DbType dbType = (DbType) selected;
                    resetConnPanel(dbType);
                } else {
                    resetConnPanel(null);
                }
            }
        });

        databaseComboBox.setRenderer(new DatabaseComboBoxCellRender());
        databaseComboBox.addItemListener(event -> {
            if (event.getStateChange() == ItemEvent.SELECTED) {
                Object selected = event.getItem();
                if (selected instanceof DatabaseInfo) {
                    DatabaseInfo databaseInfo = (DatabaseInfo) selected;
                    resetSchemaComboBox(databaseInfo.schemaList);
                } else {
                    resetSchemaComboBox(null);
                }
            }
        });

        testConnButton.addActionListener(e -> {
            ValidationInfo validationInfo = doValidate();
            if (validationInfo != null) {
                Messages.showErrorDialog(myMainPanel, validationInfo.message);
                return;
            }

            JButton jButton = (JButton) e.getSource();
            loadingPanel.setLoadingText("Test Connection!");
            loadingPanel.startLoading();

            ApplicationManager.getApplication().executeOnPooledThread(() -> {
                jButton.setEnabled(false);
                try {
                    ConnectionInfo connectionInfo = createConnectionInfo();
                    connectionInfo.setDatabase(null);
                    DatabaseDao databaseDao = DatabaseDaoFactory.create(connectionInfo);
                    boolean test = databaseDao.validConnection();
                    if (test) {
                        SwingUtilities.invokeLater(() -> {
                            List<DatabaseInfo> databaseInfoList = databaseDao.getDatabaseInfoList();
                            if (databaseInfoList != null && !databaseInfoList.isEmpty()) {
                                resetDatabaseComboBox(databaseInfoList);
                                resetSchemaComboBox(databaseInfoList.get(0).schemaList);
                            }
                            Messages.showInfoMessage(myMainPanel, "连接成功", "");
                        });
                    } else {
                        SwingUtilities.invokeLater(() -> {
                            Messages.showErrorDialog(myMainPanel, "连接失败");
                        });
                    }
                } catch (Exception ex) {
                    SwingUtilities.invokeLater(() -> {
                        Messages.showErrorDialog(myMainPanel, ex.getMessage());
                    });
                } finally {
                    loadingPanel.stopLoading();
                    jButton.setEnabled(true);
                }
            });
        });
    }

    private void resetConnPanel(DbType dbType) {
        if (dbType != null) {
            hostTextField.setText(dbType.getDefaultHost());
            portTextField.setText(dbType.getDefaultPort());
            userTextField.setText(dbType.getDefaultUser());
            passwordField.setText("");

            DatabaseInfo databaseInfo = new DatabaseInfo();
            databaseInfo.databaseName = dbType.getDefaultDatabase();
            databaseInfo.schemaList = Arrays.asList(dbType.getDefaultSchema());
            resetDatabaseComboBox(Arrays.asList(databaseInfo));
            resetSchemaComboBox(databaseInfo.schemaList);

            testConnButton.setEnabled(true);
        } else {
            dbTypeComboBox.setSelectedIndex(0);
            hostTextField.setText("");
            portTextField.setText("");
            userTextField.setText("");
            passwordField.setText("");

            resetDatabaseComboBox(null);
            resetSchemaComboBox(null);

            testConnButton.setEnabled(false);
        }
    }

    private void resetDatabaseComboBox(List<DatabaseInfo> databases) {
        databaseComboBox.removeAllItems();
        if (databases == null || databases.isEmpty()) {
            return;
        }

        for (DatabaseInfo databaseInfo : databases) {
            databaseComboBox.addItem(databaseInfo);
        }
    }

    private void resetSchemaComboBox(List<String> schemas) {
        schemaComboBox.removeAllItems();
        if (schemas == null || schemas.isEmpty()) {
            return;
        }

        for (String schema : schemas) {
            schemaComboBox.addItem(schema);
        }
    }


    private ConnectionInfo currentConnectionInfo;

    public void resetContextPanel(ConnectionInfo info) {
        currentConnectionInfo = info;
        if (info != null) {
            nameTextField.setText(info.getName());
            descriptionTextArea.setText(info.getDescription());

            dbTypeComboBox.setSelectedItem(info.getDbType());

            hostTextField.setText(info.getHost());
            portTextField.setText(info.getPort().toString());
            userTextField.setText(info.getUsername());
            passwordField.setText(info.getPasswd());


            DatabaseInfo databaseInfo = new DatabaseInfo();
            databaseInfo.databaseName = info.getDatabase();
            databaseInfo.schemaList = Arrays.asList(info.getSchema());
            resetDatabaseComboBox(Arrays.asList(databaseInfo));

            resetSchemaComboBox(databaseInfo.schemaList);
            schemaComboBox.setEditable(info.getDbType().isDefaultSchemaEdit());
        } else {
            nameTextField.setText("");
            descriptionTextArea.setText("");

            dbTypeComboBox.setSelectedIndex(0);

            hostTextField.setText("");
            portTextField.setText("");
            userTextField.setText("");
            passwordField.setText("");

            resetDatabaseComboBox(null);
            databaseComboBox.setEditable(false);

            resetSchemaComboBox(null);
            schemaComboBox.setEditable(false);
        }
    }

    public boolean saveConnectionInfo() {
        if (currentConnectionInfo == null) {
            Messages.showErrorDialog(myMainPanel, "请先选择数据源");
            return false;
        }

        ValidationInfo validationInfo = doValidate();
        if (validationInfo != null) {
            Messages.showErrorDialog(myMainPanel, validationInfo.message);
            return false;
        }

        setConnectionInfo(currentConnectionInfo);

        return true;
    }

    private void setConnectionInfo(ConnectionInfo info) {
        DatabaseInfo databaseInfo = (DatabaseInfo) databaseComboBox.getSelectedItem();
        String schema = (String) schemaComboBox.getSelectedItem();
        info.setName(nameTextField.getText()).setDescription(descriptionTextArea.getText()).setDbType((DbType) dbTypeComboBox.getSelectedItem()).setHost(hostTextField.getText()).setPort(Integer.valueOf(portTextField.getText())).setUsername(userTextField.getText()).setPasswd(new String(passwordField.getPassword())).setDatabase(databaseInfo.databaseName).setSchema(schema);
    }

    public ConnectionInfo getCurrentConnectionInfo() {
        return currentConnectionInfo;
    }

    protected ValidationInfo doValidate() {
        ValidationInfo info = null;
        if (StringUtil.isEmptyOrSpaces(nameTextField.getText())) {
            info = new ValidationInfo(Bundle.message("validate.conn.name"));
        }

        if (info == null && !(dbTypeComboBox.getSelectedItem() instanceof DbType)) {
            info = new ValidationInfo(Bundle.message("validate.conn.host"));
        }

        if (info == null && StringUtil.isEmptyOrSpaces(hostTextField.getText())) {
            info = new ValidationInfo(Bundle.message("validate.conn.host"));
        }
        String portText = portTextField.getText();
        if (info == null && StringUtil.isEmptyOrSpaces(portText)) {
            info = new ValidationInfo(Bundle.message("validate.conn.port"));
        }
        if (info == null && !StringUtils.isNumeric(portText)) {
            info = new ValidationInfo(Bundle.message("validate.conn.portnum"));
        }
        if (info == null && StringUtil.isEmptyOrSpaces(userTextField.getText())) {
            info = new ValidationInfo(Bundle.message("validate.conn.username"));
        }
		/*if (info == null) {
			if (passwordField.getPassword() == null || StringUtil.isEmptyOrSpaces(new String(passwordField.getPassword()))) {
				info = new ValidationInfo(CrudBundle.message("validate.conn.password"));
			}
		}*/
        if (!(databaseComboBox.getSelectedItem() instanceof DatabaseInfo)) {
            info = new ValidationInfo(Bundle.message("validate.conn.database"));
        }

        String schema = (String) schemaComboBox.getSelectedItem();
        if (info == null && StringUtil.isEmptyOrSpaces(schema)) {
            info = new ValidationInfo(Bundle.message("validate.conn.schema"));
        }

        return info;
    }


    @Override
    public void dispose() {

    }

    public JPanel getMyMainPanel() {
        return loadingPanel;
    }

    public ConnectionInfo getConnectionInfo() {
        ValidationInfo validationInfo = doValidate();
        if (validationInfo != null) {
            SwingUtilities.invokeLater(() -> {
                Messages.showErrorDialog(myMainPanel, validationInfo.message);
            });
            return null;
        }

        return createConnectionInfo();
    }

    private ConnectionInfo createConnectionInfo() {
        ConnectionInfo connectionInfo = new ConnectionInfo();
        setConnectionInfo(connectionInfo);
        return connectionInfo;
    }


    private void createUIComponents() {

    }


    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        myMainPanel = new JPanel();
        myMainPanel.setLayout(new BorderLayout(0, 0));
        contextPanel = new JPanel();
        contextPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
        myMainPanel.add(contextPanel, BorderLayout.CENTER);
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 25, 0), -1, -1));
        contextPanel.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        final JLabel label1 = new JLabel();
        label1.setText("连接名: ");
        panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        nameTextField = new JTextField();
        panel1.add(nameTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JLabel label2 = new JLabel();
        label2.setText("描述:");
        panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        descriptionTextArea = new JTextArea();
        panel1.add(descriptionTextArea, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(-1, 50), null, 0, false));
        final Spacer spacer1 = new Spacer();
        contextPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        tabbedPane = new JTabbedPane();
        contextPanel.add(tabbedPane, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        simpleConfigPanel = new JPanel();
        simpleConfigPanel.setLayout(new GridLayoutManager(8, 4, new Insets(20, 0, 0, 0), -1, -1));
        tabbedPane.addTab("常规", simpleConfigPanel);
        final JLabel label3 = new JLabel();
        label3.setText("数据库类型:");
        simpleConfigPanel.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final Spacer spacer2 = new Spacer();
        simpleConfigPanel.add(spacer2, new GridConstraints(7, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        dbTypeComboBox = new JComboBox();
        simpleConfigPanel.add(dbTypeComboBox, new GridConstraints(0, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JLabel label4 = new JLabel();
        label4.setText("主机: ");
        simpleConfigPanel.add(label4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        hostTextField = new JTextField();
        simpleConfigPanel.add(hostTextField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JLabel label5 = new JLabel();
        label5.setText("用户名:");
        simpleConfigPanel.add(label5, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        userTextField = new JTextField();
        simpleConfigPanel.add(userTextField, new GridConstraints(2, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label6 = new JLabel();
        label6.setText("密码:");
        simpleConfigPanel.add(label6, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JLabel label7 = new JLabel();
        label7.setText("数据库：");
        simpleConfigPanel.add(label7, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridLayoutManager(1, 1, new Insets(15, 0, 0, 0), -1, -1));
        simpleConfigPanel.add(panel2, new GridConstraints(7, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        final Spacer spacer3 = new Spacer();
        panel2.add(spacer3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
        passwordField = new JPasswordField();
        simpleConfigPanel.add(passwordField, new GridConstraints(3, 1, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
        final JLabel label8 = new JLabel();
        label8.setText("端口:");
        simpleConfigPanel.add(label8, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        portTextField = new JTextField();
        simpleConfigPanel.add(portTextField, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JLabel label9 = new JLabel();
        label9.setText("schema:");
        simpleConfigPanel.add(label9, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
        simpleConfigPanel.add(panel3, new GridConstraints(4, 2, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        testConnButton = new JButton();
        testConnButton.setText("测试");
        panel3.add(testConnButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final Spacer spacer4 = new Spacer();
        panel3.add(spacer4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
        final JPanel panel4 = new JPanel();
        panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
        simpleConfigPanel.add(panel4, new GridConstraints(5, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        final Spacer spacer5 = new Spacer();
        panel4.add(spacer5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
        schemaComboBox = new JComboBox();
        simpleConfigPanel.add(schemaComboBox, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        databaseComboBox = new JComboBox();
        simpleConfigPanel.add(databaseComboBox, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
        final JPanel panel5 = new JPanel();
        panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
        tabbedPane.addTab("高级", panel5);
        final JPanel panel6 = new JPanel();
        panel6.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
        contextPanel.add(panel6, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return myMainPanel;
    }
}
